# -*- coding: utf-8 -*-
# @Time     : 2021/11/30 21:16
# @Author   : wljess
# @File     : 基于队列.py
# @Describe : 
# @Software : PyCharm

import time
from multiprocessing import Process, Queue


def func(a, b, q):
    data = a + b
    q.put(data)
    q.put(5)
    q.put(10)
    q.put(20)
    q.put(100)


if __name__ == '__main__':
    q = Queue(3)

    p = Process(target=func, args=(10, 20, q))
    p.start()
    time.sleep(0.5)
    print(f"队列的长度:{q.qsize()}")
    print(f"判断队列是否已满：{q.full()}")
    print(q.get())
    print(q.get())
    print(f"判断队列是否为空：{q.empty()}")
    print(q.get())
    print(q.get())  # 队列为空阻塞
    print(q.get())  # 队列为空阻塞
    print(f"判断队列是否为空：{q.empty()}")
    print(f"判断队列是否已满：{q.full()}")
    print(q.get())  # 队列为空阻塞


